package org.rambadger.command.command;

import org.axonframework.commandhandling.annotation.TargetAggregateIdentifier;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;
import org.joda.time.DateTime;
import org.rambadger.command.validation.UrlIdentifier;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

/**
 * {@link org.rambadger.command.command Command} class for creating new {@link org.rambadger.command.model.AssignmentEntity Assignments}.
 */
public class CreateAssignment {
    @TargetAggregateIdentifier
    private final String platformId;
    private final String assignmentId;
    private final String assignmentName;
    private final String description;

    private final int submissionPoints;
    private final int reviewPoints;

    private final String associatedTrack;

    /**
     * Instantiates a new CreateAssignment command.
     *
     * @param platformId The id of the platform that the assignment is associated with
     * @param assignmentId The <i>per platform</i> assignment ID
     * @param assignmentName the assignment name
     * @param description the description
     * @param submissionPoints the maximum number of submission point a reviewer may award a user for this assignment
     * @param reviewPoints how many review points a reviewer receives for completing a review of a submission for this assignment
     */
    public CreateAssignment(String platformId, String assignmentId, String assignmentName, String description, int submissionPoints, int reviewPoints, String associatedTrack) {
        this.platformId = platformId;
        this.assignmentId = assignmentId;
        this.assignmentName = assignmentName;
        this.description = description;
        this.submissionPoints = submissionPoints;
        this.reviewPoints = reviewPoints;
        this.associatedTrack = associatedTrack;
        //new DateTime()
    }

    /**
     * Gets id of the platform that the new assignment will be associated with.
     *
     * @return the platform id
     */
    @UrlIdentifier @NotNull
    public String getPlatformId() {
        return platformId;
    }

    /**
     * URL Identifier of the assignment being created
     * <p>
     * Because the assignment IDs are per {@link org.rambadger.command.model.PlatformAggregate Platform} you will need both to reference an assignment.
     *
     * @return the assignment id
     */
    @UrlIdentifier @NotNull
    public String getAssignmentId() {
        return assignmentId;
    }

    /**
     * Gets assignment name.
     *
     * @return the assignment name
     */
    @NotBlank @Length(max = 64)
    public String getAssignmentName() {
        return assignmentName;
    }

    /**
     * Gets description.
     *
     * @return the description
     */
    @NotBlank @Length(max = 4096)
    public String getDescription() {
        return description;
    }

    /**
     * Gets the maximum number of submission points that may be awarded to a user for completing the assignment.
     *
     * @return the maximum submission points awardable.
     */
    @Min(0)
    public int getSubmissionPoints() {
        return submissionPoints;
    }

    /**
     * Gets the number review points awarded to a reviewer for completing a review of this assignment.
     *
     * @return the review points awarded
     */
    @Min(0)
    public int getReviewPoints() {
        return reviewPoints;
    }

    public String getAssociatedTrack(){
        return associatedTrack;
    }
}
